<template>
  <div>
    <el-row style="margin-top: 20px">
      <el-col :span="12">
        <el-form ref="todayuserform" :model="todayuserform" label-width="120px">
          <h2 style="text-align:center">每日新增人员几率设置</h2>
          <el-row type="flex" justify="center">
            <div class="line"></div>
          </el-row>
          <el-row type="flex" justify="center">
            <el-col :span="12">
              <el-form-item label="id" prop="id" v-show="false">
                <el-input
                  type="text"
                  placeholder="请输入整数"
                  auto-complete="off"
                  v-model="todayuserform.id"
                ></el-input>
              </el-form-item>
              <el-form-item label="人数为0的几率" prop="per0">
                <el-input
                  type="text"
                  placeholder="请输入整数"
                  auto-complete="off"
                  v-model="todayuserform.per0"
                ></el-input>
              </el-form-item>
              <el-form-item label="人数为1的几率" prop="per1">
                <el-input
                  type="text"
                  placeholder="请输入整数"
                  auto-complete="off"
                  v-model="todayuserform.per1"
                ></el-input>
              </el-form-item>
              <el-form-item label="人数为2的几率" prop="per2">
                <el-input
                  type="text"
                  placeholder="请输入整数"
                  auto-complete="off"
                  v-model="todayuserform.per2"
                ></el-input>
              </el-form-item>
              <el-form-item label="人数为3的几率" prop="per3">
                <el-input
                  type="text"
                  placeholder="请输入整数"
                  auto-complete="off"
                  v-model="todayuserform.per3"
                ></el-input>
              </el-form-item>
              <el-form-item label="人数为4的几率" prop="per4">
                <el-input
                  type="text"
                  placeholder="请输入整数"
                  auto-complete="off"
                  v-model="todayuserform.per4"
                ></el-input>
              </el-form-item>
              <el-form-item label="人数为5的几率" prop="per5">
                <el-input
                  type="text"
                  placeholder="请输入整数"
                  auto-complete="off"
                  v-model="todayuserform.per5"
                ></el-input>
              </el-form-item>
            </el-col>
          </el-row>
          <el-row type="flex" justify="center" style="margin-top: 20px">
            <el-button type="primary" @click="submitTodayUserConfig()">保存</el-button>
          </el-row>
        </el-form>
      </el-col>
    </el-row>
    <el-row style="margin-top: 20px">
      <el-col :span="12">
        <el-form ref="goodsform" :model="goodsform" label-width="100px">
          <h2 style="text-align:center">商品名称排序</h2>
          <el-row type="flex" justify="center">
            <div class="line"></div>
          </el-row>
          <el-row type="flex" justify="center">
            <el-col :span="18">
              <el-button size="mini" @click="addRow()">+</el-button>
              <el-table
                :data="goodsformlist"
                v-loading.body="listLoading"
                element-loading-text="拼命加载中"
                border
                fit
                highlight-current-row
                ref="goodsformlist"
              >
                <el-table-column align="center" label="序号" prop="id" width="80" v-if="false"></el-table-column>
                <el-table-column align="center" label="商品名称" prop="name" width="250">
                  <template slot-scope="scope">
                    <el-form :model="scope.row" :rules="goodsrules">
                      <el-form-item prop="name">
                        <el-input size="mini" v-model="scope.row.name" placeholder="请输入内容"></el-input>
                      </el-form-item>
                    </el-form>
                  </template>
                </el-table-column>
                <el-table-column align="center" label="商品销售数量" prop="value" width="150">
                  <template slot-scope="scope">
                    <el-form :model="scope.row" :rules="goodsrules">
                      <el-form-item prop="value">
                        <el-input
                          type="number"
                          size="mini"
                          v-model="scope.row.value"
                          placeholder="请输入内容"
                        ></el-input>
                      </el-form-item>
                    </el-form>
                  </template>
                </el-table-column>

                <el-table-column align="center" label="管理" fixed="right" width="200">
                  <template slot-scope="scope">
                    <div>
                      <el-button
                        type="primary"
                        icon="edit"
                        @click="updategoods(scope.row)"
                        v-if="scope.row.id!=''"
                      >修改</el-button>
                      <el-button
                        type="danger"
                        icon="delete"
                        @click="removegoods(scope.$index,goodsformlist)"
                      >删除</el-button>
                    </div>
                  </template>
                </el-table-column>
              </el-table>
            </el-col>
          </el-row>
          <el-row type="flex" justify="center" style="margin-top: 20px">
            <el-button type="primary" @click="submit()">保存</el-button>
          </el-row>
        </el-form>
      </el-col>
      <el-col :span="12">
        <h2 style="text-align:center">商品类型排序</h2>
        <el-row type="flex" justify="center">
          <div class="line"></div>
        </el-row>
        <el-form ref="goodstypeform" :model="goodstypeform" label-width="130px">
          <el-row type="flex" justify="center">
            <el-col :span="18">
              <el-button size="mini" @click="addtypeRow()">+</el-button>
              <el-table
                :data="goodstypeformlist"
                v-loading.body="listLoading"
                element-loading-text="拼命加载中"
                border
                fit
                highlight-current-row
                ref="goodstypeformlist"
              >
                <el-table-column align="center" label="序号" prop="id" width="80" v-if="false"></el-table-column>
                <el-table-column align="center" label="品类名称" prop="name" width="250">
                  <template slot-scope="scope">
                    <el-form :model="scope.row" :rules="goodstyperules">
                      <el-form-item prop="name">
                        <el-input size="mini" v-model="scope.row.name" placeholder="请输入内容"></el-input>
                      </el-form-item>
                    </el-form>
                  </template>
                </el-table-column>
                <el-table-column align="center" label="品类销售数量" prop="value" width="150">
                  <template slot-scope="scope">
                    <el-form :model="scope.row" :rules="goodstyperules">
                      <el-form-item prop="value">
                        <el-input
                          type="number"
                          size="mini"
                          v-model="scope.row.value"
                          placeholder="请输入内容"
                        ></el-input>
                      </el-form-item>
                    </el-form>
                  </template>
                </el-table-column>

                <el-table-column align="center" label="管理" fixed="right" width="200">
                  <template slot-scope="scope">
                    <div>
                      <el-button
                        type="primary"
                        icon="edit"
                        @click="updategoodstype(scope.row)"
                        v-if="scope.row.id!=''"
                      >修改</el-button>
                      <el-button
                        type="danger"
                        icon="delete"
                        @click="removegoodstype(scope.$index,goodstypeformlist)"
                      >删除</el-button>
                    </div>
                  </template>
                </el-table-column>
              </el-table>
            </el-col>
          </el-row>
          <el-row type="flex" justify="center" style="margin-top: 20px">
            <el-button type="primary" @click="submitType()">保存</el-button>
          </el-row>
        </el-form>
      </el-col>
    </el-row>
    <el-row type="flex" justify="center">
      <div class="allline"></div>
    </el-row>
    <el-row>
      <el-col :span="12">
        <el-form ref="goodstyperadioform" :model="goodstyperadioform" label-width="100px">
          <h2 style="text-align:center">品类占比排序</h2>
          <el-row type="flex" justify="center">
            <div class="line"></div>
          </el-row>
          <el-row type="flex" justify="center">
            <el-col :span="18">
              <el-button size="mini" @click="addradioRow()">+</el-button>
              <el-table
                :data="goodstyperadioformlist"
                v-loading.body="listLoading"
                element-loading-text="拼命加载中"
                border
                fit
                highlight-current-row
                ref="goodstyperadioformlist"
              >
                <el-table-column align="center" label="序号" prop="id" width="80" v-if="false"></el-table-column>
                <el-table-column align="center" label="品类名称" prop="name" width="250">
                  <template slot-scope="scope">
                    <el-form :model="scope.row" :rules="goodstyperadiorules">
                      <el-form-item prop="name">
                        <el-input size="mini" v-model="scope.row.name" placeholder="请输入内容"></el-input>
                      </el-form-item>
                    </el-form>
                  </template>
                </el-table-column>
                <el-table-column align="center" label="品类占比系数" prop="value" width="150">
                  <template slot-scope="scope">
                    <el-form :model="scope.row" :rules="goodstyperadiorules">
                      <el-form-item prop="value">
                        <el-input
                          type="number"
                          size="mini"
                          v-model="scope.row.value"
                          placeholder="请输入内容"
                        ></el-input>
                      </el-form-item>
                    </el-form>
                  </template>
                </el-table-column>

                <el-table-column align="center" label="管理" fixed="right" width="200">
                  <template slot-scope="scope">
                    <div>
                      <el-button
                        type="primary"
                        icon="edit"
                        @click="updategoodstyperadio(scope.row)"
                        v-if="scope.row.id!=''"
                      >修改</el-button>
                      <el-button
                        type="danger"
                        icon="delete"
                        @click="removegoodstyperadio(scope.$index,goodstyperadioformlist)"
                      >删除</el-button>
                    </div>
                  </template>
                </el-table-column>
              </el-table>
            </el-col>
          </el-row>
          <el-row type="flex" justify="center" style="margin-top: 20px">
            <el-button type="primary" @click="submitRadio()">保存</el-button>
          </el-row>
        </el-form>
      </el-col>

      <el-col :span="12">
        <el-form ref="funnelform" :model="funnelform" label-width="100px">
          <h2 style="text-align:center">用户流量转化排序</h2>
          <el-row type="flex" justify="center">
            <div class="line"></div>
          </el-row>
          <el-row type="flex" justify="center">
            <el-col :span="18">
              <el-button size="mini" @click="addfunnelRow()">+</el-button>
              <el-table
                :data="funnelformlist"
                v-loading.body="listLoading"
                element-loading-text="拼命加载中"
                border
                fit
                highlight-current-row
                ref="funnelformlist"
              >
                <el-table-column align="center" label="序号" prop="id" width="80" v-if="false"></el-table-column>
                <el-table-column align="center" label="参数名称" prop="name" width="250">
                  <template slot-scope="scope">
                    <el-form :model="scope.row" :rules="funnelrules">
                      <el-form-item prop="name">
                        <el-input size="mini" v-model="scope.row.name" placeholder="请输入内容"></el-input>
                      </el-form-item>
                    </el-form>
                  </template>
                </el-table-column>
                <el-table-column align="center" label="参数值" prop="value" width="150">
                  <template slot-scope="scope">
                    <el-form :model="scope.row" :rules="funnelrules">
                      <el-form-item prop="value">
                        <el-input
                          type="number"
                          size="mini"
                          v-model="scope.row.value"
                          placeholder="请输入内容"
                        ></el-input>
                      </el-form-item>
                    </el-form>
                  </template>
                </el-table-column>

                <el-table-column align="center" label="管理" fixed="right" width="200">
                  <template slot-scope="scope">
                    <div>
                      <el-button
                        type="primary"
                        icon="edit"
                        @click="updatefunnel(scope.row)"
                        v-if="scope.row.id!=''"
                      >修改</el-button>
                      <el-button
                        type="danger"
                        icon="delete"
                        @click="removefunnel(scope.$index,funnelformlist)"
                      >删除</el-button>
                    </div>
                  </template>
                </el-table-column>
              </el-table>
            </el-col>
          </el-row>
          <el-row type="flex" justify="center" style="margin-top: 20px">
            <el-button type="primary" @click="submitFunnel()">保存</el-button>
          </el-row>
        </el-form>
      </el-col>
    </el-row>
    <el-row type="flex" justify="center">
      <div class="allline"></div>
    </el-row>
    <el-row>
      <el-col :span="12">
        <el-form ref="regionform" :model="regionform" label-width="100px">
          <h2 style="text-align:center">本月全国订单迁移图</h2>
          <el-row type="flex" justify="center">
            <div class="line"></div>
          </el-row>
          <el-row type="flex" justify="center">
            <el-col :span="18">
              <el-button size="mini" @click="addregionRow()">+</el-button>
              <el-table
                :data="regionformlist"
                v-loading.body="listLoading"
                element-loading-text="拼命加载中"
                border
                fit
                highlight-current-row
                ref="regionformlist"
              >
                <el-table-column align="center" label="序号" prop="id" width="80" v-if="false"></el-table-column>
                <el-table-column align="center" label="地区名称" prop="name" width="250">
                  <template slot-scope="scope">
                    <el-form :model="scope.row" :rules="regionrules">
                      <el-form-item prop="name">
                        <el-input size="mini" v-model="scope.row.name" placeholder="请输入内容"></el-input>
                      </el-form-item>
                    </el-form>
                  </template>
                </el-table-column>
                <el-table-column align="center" label="订单数量" prop="value" width="150">
                  <template slot-scope="scope">
                    <el-form :model="scope.row" :rules="regionrules">
                      <el-form-item prop="value">
                        <el-input
                          type="number"
                          size="mini"
                          v-model="scope.row.value"
                          placeholder="请输入内容"
                        ></el-input>
                      </el-form-item>
                    </el-form>
                  </template>
                </el-table-column>

                <el-table-column align="center" label="管理" fixed="right" width="200">
                  <template slot-scope="scope">
                    <div>
                      <el-button
                        type="primary"
                        icon="edit"
                        @click="updateregion(scope.row)"
                        v-if="scope.row.id!=''"
                      >修改</el-button>
                      <el-button
                        type="danger"
                        icon="delete"
                        @click="removeregion(scope.$index,regionformlist)"
                      >删除</el-button>
                    </div>
                  </template>
                </el-table-column>
              </el-table>
            </el-col>
          </el-row>
          <el-row type="flex" justify="center" style="margin-top: 20px">
            <el-button type="primary" @click="submitRegion()">保存</el-button>
          </el-row>
        </el-form>
      </el-col>

      <el-col :span="12">
        <el-form ref="saletargetform" :model="saletargetform" label-width="100px">
          <h2 style="text-align:center">月度销量目标值</h2>
          <el-row type="flex" justify="center">
            <div class="line"></div>
          </el-row>
          <el-row type="flex" justify="center">
            <el-col :span="18">
              <el-button size="mini" @click="addsaletargetRow()">+</el-button>
              <el-table
                :data="saletargetformlist"
                v-loading.body="listLoading"
                element-loading-text="拼命加载中"
                border
                fit
                highlight-current-row
                ref="saletargetformlist"
              >
                <el-table-column align="center" label="序号" prop="id" width="80" v-if="false"></el-table-column>
                <el-table-column align="center" label="月份" prop="name" width="250">
                  <template slot-scope="scope">
                    <el-form :model="scope.row" :rules="monthrules">
                      <el-form-item prop="name">
                        <el-select
                          v-model="scope.row.name"
                          placeholder="请选择"
                          @change="onSelectedDrug"
                        >
                          <el-option
                            v-for="item in options"
                            :key="item.value"
                            :label="item.name"
                            :value="item.value"
                          ></el-option>
                        </el-select>
                      </el-form-item>
                    </el-form>
                  </template>
                </el-table-column>
                <el-table-column align="center" label="目标销量" prop="value" width="150">
                  <template slot-scope="scope">
                    <el-form :model="scope.row" :rules="monthrules">
                      <el-form-item prop="value">
                        <el-input
                          type="number"
                          size="mini"
                          v-model="scope.row.value"
                          placeholder="请输入内容"
                        ></el-input>
                      </el-form-item>
                    </el-form>
                  </template>
                </el-table-column>

                <el-table-column align="center" label="管理" fixed="right" width="200">
                  <template slot-scope="scope">
                    <div>
                      <el-button
                        type="primary"
                        icon="edit"
                        @click="updatesaletarget(scope.row)"
                        v-if="scope.row.id!=''"
                      >修改</el-button>
                      <el-button
                        type="danger"
                        icon="delete"
                        @click="removesaletarget(scope.$index,saletargetformlist)"
                      >删除</el-button>
                    </div>
                  </template>
                </el-table-column>
              </el-table>
            </el-col>
          </el-row>
          <el-row type="flex" justify="center" style="margin-top: 20px">
            <el-button type="primary" @click="submitSaletarget()">保存</el-button>
          </el-row>
        </el-form>
      </el-col>
    </el-row>
  </div>
</template>
<script>
export default {
  name: "dashboard",
  data() {
    let checkNum = (rule, value, callback) => {
      if (!value) {
        return new Error("必填信息");
      } else {
        if (!/^[a-z0-9]+$/.test(value)) {
          callback(new Error("请输入数字值"));
        } else {
          if (value.length > 9) {
            callback(new Error("数字长度不能大于9位"));
          } else {
            callback();
          }
        }
      }
    };
    let checkFloatNum = (rule, value, callback) => {
      if (!value) {
        return new Error("必填信息");
      } else {
        if (!/^0\.\d{2}$/.test(value)) {
          callback(new Error("请输入小于1并且小数点后两位的非负小数!"));
        } else {
          if (value.length > 9) {
            callback(new Error("数字长度不能大于9位"));
          } else {
            callback();
          }
        }
      }
    };
    return {
      listLoading: false, //数据加载等待动画,
      goodsformlist: [],
      goodsform: {},
      goodstypeform: {},
      goodstypeformlist: [],
      goodstyperadioform: {},
      goodstyperadioformlist: [],
      funnelform: {},
      funnelformlist: [],
      regionform: {},
      regionformlist: [],
      saletargetform: {},
      saletargetformlist: [],
      todayuserform: {
        per0: "",
        per1: "",
        per2: "",
        per3: "",
        per4: "",
        per5: ""
      },
      monthLabel: "",
      options: [
        {
          value: 1,
          label: "1"
        },
        {
          value: 2,
          label: "2"
        },
        {
          value: 3,
          label: "3"
        },
        {
          value: 4,
          label: "4"
        },
        {
          value: 5,
          label: "5"
        },
        {
          value: 6,
          label: "6"
        },
        {
          value: 7,
          label: "7"
        },
        {
          value: 8,
          label: "8"
        },
        {
          value: 9,
          label: "9"
        },
        {
          value: 10,
          label: "10"
        },
        {
          value: 11,
          label: "11"
        },
        {
          value: 12,
          label: "12"
        }
      ],
      goodsrules: {
        name: [{ required: true, message: "必填信息", trigger: "blur" }],
        value: [
          { required: true, message: "必填信息" },
          { validator: checkNum, trigger: "blur" }
        ]
      },
      goodstyperules: {
        name: [{ required: true, message: "必填信息", trigger: "blur" }],
        value: [
          { required: true, message: "必填信息" },
          { validator: checkNum, trigger: "blur" }
        ]
      },
      goodstyperadiorules: {
        name: [{ required: true, message: "必填信息", trigger: "blur" }],
        value: [
          { required: true, message: "必填信息" },
          { validator: checkFloatNum, trigger: "blur" }
        ]
      },
      funnelrules: {
        name: [{ required: true, message: "必填信息", trigger: "blur" }],
        value: [
          { required: true, message: "必填信息" },
          { validator: checkNum, trigger: "blur" }
        ]
      },
      regionrules: {
        name: [{ required: true, message: "必填信息", trigger: "blur" }],
        value: [
          { required: true, message: "必填信息" },
          { validator: checkNum, trigger: "blur" }
        ]
      },
      monthrules: {
        name: [{ required: true, message: "必填信息", trigger: "blur" }],
        value: [
          { required: true, message: "必填信息" },
          { validator: checkNum, trigger: "blur" }
        ]
      }
    };
  },
  created() {
    this.getGoods();
    this.getGoodstype();
    this.getGoodstyperadio();
    this.getFunnel();
    this.getRegion();
    this.getSaleTarget();
    this.getTodayUserConfig();
  },
  methods: {
    submit() {
      let params = new FormData();
      params.append("goodsformlist", JSON.stringify(this.goodsformlist));
      this.api({
        url: "/goods/add",
        method: "post",
        data: params
      }).then(data => {
        this.listLoading = false;
        this.getGoods();
        this.$message({
          message: "保存成功",
          type: "success"
        });
      });
    },
    submitTodayUserConfig() {
      let params = new FormData();
      params.append("todayuserform", JSON.stringify(this.todayuserform));
      this.api({
        url: "/today-user-config/add",
        method: "post",
        data: params
      }).then(data => {
        this.listLoading = false;
        this.getGoods();
        this.$message({
          message: "保存成功",
          type: "success"
        });
      });
    },
    submitType() {
      let params = new FormData();
      params.append(
        "goodstypeformlist",
        JSON.stringify(this.goodstypeformlist)
      );
      this.api({
        url: "/goods-type/add",
        method: "post",
        data: params
      }).then(data => {
        this.listLoading = false;
        this.getGoodstype();
        this.$message({
          message: "保存成功",
          type: "success"
        });
      });
    },
    submitRadio() {
      let params = new FormData();
      params.append(
        "goodstyperadioformlist",
        JSON.stringify(this.goodstyperadioformlist)
      );
      this.api({
        url: "/goods-type-radio/add",
        method: "post",
        data: params
      }).then(data => {
        this.listLoading = false;
        this.getGoodstyperadio();
        this.$message({
          message: "保存成功",
          type: "success"
        });
      });
    },
    submitFunnel() {
      let params = new FormData();
      params.append("funnelformlist", JSON.stringify(this.funnelformlist));
      this.api({
        url: "/funnel/add",
        method: "post",
        data: params
      }).then(data => {
        this.listLoading = false;
        this.getFunnel();
        this.$message({
          message: "保存成功",
          type: "success"
        });
      });
    },

    submitRegion() {
      let params = new FormData();
      params.append("regionformlist", JSON.stringify(this.regionformlist));
      this.api({
        url: "/region/add",
        method: "post",
        data: params
      }).then(data => {
        this.listLoading = false;
        this.getRegion();
        this.$message({
          message: "保存成功",
          type: "success"
        });
      });
    },
    submitRegion() {
      let params = new FormData();
      params.append("regionformlist", JSON.stringify(this.regionformlist));
      this.api({
        url: "/region/add",
        method: "post",
        data: params
      }).then(data => {
        this.listLoading = false;
        this.getRegion();
        this.$message({
          message: "保存成功",
          type: "success"
        });
      });
    },
    submitSaletarget() {
      let params = new FormData();
      params.append(
        "saletargetformlist",
        JSON.stringify(this.saletargetformlist)
      );
      this.api({
        url: "/sale-target/add",
        method: "post",
        data: params
      }).then(data => {
        this.listLoading = false;
        this.getSaleTarget();
        this.$message({
          message: "保存成功",
          type: "success"
        });
      });
    },
    addRow() {
      let d = {
        id: "",
        name: "",
        value: ""
      };
      this.goodsformlist.push(d);
      setTimeout(() => {
        this.$refs.goodsformlist.setCurrentRow(d);
      }, 10);
    },
    addtypeRow() {
      let d = {
        id: "",
        name: "",
        value: ""
      };
      this.goodstypeformlist.push(d);
      setTimeout(() => {
        this.$refs.goodstypeformlist.setCurrentRow(d);
      }, 10);
    },
    addradioRow() {
      let d = {
        id: "",
        name: "",
        value: ""
      };
      this.goodstyperadioformlist.push(d);
      setTimeout(() => {
        this.$refs.goodstyperadioformlist.setCurrentRow(d);
      }, 10);
    },
    addfunnelRow() {
      let d = {
        id: "",
        name: "",
        value: ""
      };
      this.funnelformlist.push(d);
      setTimeout(() => {
        this.$refs.funnelformlist.setCurrentRow(d);
      }, 10);
    },
    addregionRow() {
      let d = {
        id: "",
        name: "",
        value: ""
      };
      this.regionformlist.push(d);
      setTimeout(() => {
        this.$refs.regionformlist.setCurrentRow(d);
      }, 10);
    },
    addsaletargetRow() {
      let d = {
        id: "",
        name: "",
        value: ""
      };
      this.saletargetformlist.push(d);
      setTimeout(() => {
        this.$refs.saletargetformlist.setCurrentRow(d);
      }, 10);
    },
    getTodayUserConfig() {
      this.api({
        url: "/today-user-config/get",
        method: "get"
      }).then(data => {
        this.listLoading = false;
        this.todayuserform = data;
      });
    },
    getGoods() {
      this.api({
        url: "/goods/list",
        method: "get"
      }).then(data => {
        this.listLoading = false;
        this.goodsformlist = data;
      });
    },
    getGoodstype() {
      this.api({
        url: "/goods-type/list",
        method: "get"
      }).then(data => {
        this.listLoading = false;
        this.goodstypeformlist = data;
      });
    },
    getGoodstyperadio() {
      this.api({
        url: "/goods-type-radio/list",
        method: "get"
      }).then(data => {
        this.listLoading = false;
        this.goodstyperadioformlist = data;
      });
    },
    getFunnel() {
      this.api({
        url: "/funnel/list",
        method: "get"
      }).then(data => {
        this.listLoading = false;
        this.funnelformlist = data;
      });
    },
    getRegion() {
      this.api({
        url: "/region/list",
        method: "get"
      }).then(data => {
        this.listLoading = false;
        this.regionformlist = data;
      });
    },
    getSaleTarget() {
      this.api({
        url: "/sale-target/list",
        method: "get"
      }).then(data => {
        this.listLoading = false;
        this.saletargetformlist = data;
      });
    },
    updategoods(row) {
      let params = new FormData();
      params.append("goods", JSON.stringify(row));
      this.api({
        url: "/goods/update",
        method: "post",
        data: params
      }).then(data => {
        this.listLoading = false;
        this.getGoods();
        this.$message({
          message: "保存成功",
          type: "success"
        });
      });
    },

    updategoodstype(row) {
      let params = new FormData();
      params.append("goodstype", JSON.stringify(row));
      this.api({
        url: "/goods-type/update",
        method: "post",
        data: params
      }).then(data => {
        this.listLoading = false;
        this.getGoodstype();
        this.$message({
          message: "保存成功",
          type: "success"
        });
      });
    },
    updategoodstyperadio(row) {
      let params = new FormData();
      params.append("goodsradio", JSON.stringify(row));
      this.api({
        url: "/goods-type-radio/update",
        method: "post",
        data: params
      }).then(data => {
        this.listLoading = false;
        this.getGoodstyperadio();
        this.$message({
          message: "保存成功",
          type: "success"
        });
      });
    },
    updatefunnel(row) {
      let params = new FormData();
      params.append("funnel", JSON.stringify(row));
      this.api({
        url: "/funnel/update",
        method: "post",
        data: params
      }).then(data => {
        this.listLoading = false;
        this.getFunnel();
        this.$message({
          message: "保存成功",
          type: "success"
        });
      });
    },
    updateregion(row) {
      let params = new FormData();
      params.append("region", JSON.stringify(row));
      this.api({
        url: "/region/update",
        method: "post",
        data: params
      }).then(data => {
        this.listLoading = false;
        this.getRegion();
        this.$message({
          message: "保存成功",
          type: "success"
        });
      });
    },
    updatesaletarget(row) {
      let params = new FormData();
      params.append("saletarget", JSON.stringify(row));
      this.api({
        url: "/sale-target/update",
        method: "post",
        data: params
      }).then(data => {
        this.listLoading = false;
        this.getSaleTarget();
        this.$message({
          message: "保存成功",
          type: "success"
        });
      });
    },
    removegoods(index, rows) {
      if (rows[index].id == "") {
        rows.splice(index, 1);
      } else {
        let params = new FormData();
        params.append("id", rows[index].id);
        this.api({
          url: "/goods/del",
          method: "post",
          data: params
        }).then(data => {
          this.listLoading = false;
          this.getGoods();
        });
      }
    },
    removegoodstype(index, rows) {
      if (rows[index].id == "") {
        rows.splice(index, 1);
      } else {
        let params = new FormData();
        params.append("id", rows[index].id);
        this.api({
          url: "/goods-type/del",
          method: "post",
          data: params
        }).then(data => {
          this.listLoading = false;
          this.getGoodstype();
        });
      }
    },
    removegoodstyperadio(index, rows) {
      if (rows[index].id == "") {
        rows.splice(index, 1);
      } else {
        let params = new FormData();
        params.append("id", rows[index].id);
        this.api({
          url: "/goods-type-radio/del",
          method: "post",
          data: params
        }).then(data => {
          this.listLoading = false;
          this.getGoodstyperadio();
        });
      }
    },
    removefunnel(index, rows) {
      if (rows[index].id == "") {
        rows.splice(index, 1);
      } else {
        let params = new FormData();
        params.append("id", rows[index].id);
        this.api({
          url: "/funnel/del",
          method: "post",
          data: params
        }).then(data => {
          this.listLoading = false;
          this.getFunnel();
        });
      }
    },
    removeregion(index, rows) {
      if (rows[index].id == "") {
        rows.splice(index, 1);
      } else {
        let params = new FormData();
        params.append("id", rows[index].id);
        this.api({
          url: "/region/del",
          method: "post",
          data: params
        }).then(data => {
          this.listLoading = false;
          this.getRegion();
        });
      }
    },
    removesaletarget(index, rows) {
      if (rows[index].id == "") {
        rows.splice(index, 1);
      } else {
        let params = new FormData();
        params.append("id", rows[index].id);
        this.api({
          url: "/sale-target/del",
          method: "post",
          data: params
        }).then(data => {
          this.listLoading = false;
          this.getSaleTarget();
        });
      }
    },
    onSelectedDrug(val) {
      let obj = {};
      obj = this.options.find(item => {
        return item.value === val;
      });
      this.monthLabel = obj.label;
    }
  }
};
</script>
<style scoped>
.line {
  width: 800px;
  margin-top: 20px;
  margin-bottom: 40px;
  height: 1px;
  border-top: solid #acc0d8 1px;
}
.allline {
  width: 100%;
  margin-top: 40px;
  margin-bottom: 20px;
  height: 1px;
  border-top: solid #acc0d8 1px;
}
.el-form-item {
  text-align: center;
}
</style>